package com.cicc.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cicc.springboot.common.dto.OrderWithItemsDTO;
import com.cicc.springboot.entity.PurchaseOrderEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * Author: 张月鹿
 */

@Mapper
public interface OrderMapper extends BaseMapper<PurchaseOrderEntity> {
    @Select("SELECT o.order_code, o.supplier_name, o.state, o.total_price_without_tax, o.order_currency, " +
            "o.purchase_org_desc, o.order_type, o.purchase_org, o.need_confirm, o.publish_asn, o.order_description, " +
            "o.batch_id, o.order_notes, oi.item_state, oi.item_no, oi.material_desc, oi.number, oi.confirmed_quantity, " +
            "oi.deliver_date, oi.confirmed_delivery_date, oi.price, oi.confirmed_price_without_tax, " +
            "oi.tax_included_or_not, oi.tax_rate, oi.requested_price_with_tax, oi.confirmed_price_with_tax " +
            "FROM srm_purchase_order o " +
            "LEFT JOIN srm_purchase_order_item oi ON o.order_code = oi.order_code " +
            "WHERE o.order_code = #{orderCode}")
    List<OrderWithItemsDTO> getOrderWithItems(@Param("orderCode")String orderCode);
}
